<?php
require_once("../../../config.inc.php");
require_once("../../../app/_inc/include.php");

$objUser = $_SESSION[USEROBJ];

$numElem = 0;
$errMsg = (isset($_REQUEST['msg']))?sxGPC($_REQUEST['msg']):"";
//carico l'elenco dei moduli'
$sSQL = "SELECT m.module, m.description AS m_description "
	.", f.functional_area, f.description AS f_description "
	.", s.sub_module, s.description AS s_description "
	." FROM module m "
	." LEFT JOIN functional_area f ON f.module = m.module "
	." LEFT JOIN sub_module s ON s.module = m.module AND s.functional_area = f.functional_area"
	." ORDER BY m.module,f.functional_area, s.sub_module";
if(!$query = $objSDAO->query($sSQL, "mod")){
	$errMsg = $objSDAO->error;
	$errCode = $objSDAO->errno;
}
//output HTML
$aOpz = array("kMenu"=>'pro.mod');
echo(headerHTML($aOpz));
echo(bodyHTML($aOpz));
//output comandi
$aCmd = array("ins"=>array("pag"=>"moduleIns.php?",
										"title"=>_t("add module"),
										"text"=>_t("new  module"),
										"perm"=>"newmod"),
					"back"=>array("pag"=>$objUser->getHistory(-1,false),
										"title"=>$objUser->getHistoryText(-1),
										"text"=>$objUser->getHistoryText(-1),
										"perm"=>"")
					);
echo(commandsHTML($aCmd));	
//output dei dati
echo("<table class='tabl01' width=\"100%\" cellpadding=\"3\" cellspacing=\"2\">\n");
echo("<tr>" .
		"<td class=\"titl01\"colspan=\"6\">List of Modules / Functional-Areas / Sub-Modules</td>" .
	"</tr>\n");
$row = $objSDAO->fetch("mod");
while($row){
	$module = $row["module"];
	echo("<tr>" .
		"<td class=\"text01\" valign='top' width='1%' style='font-weight:bold;'><a class=\"text01\" ".
			goToPag("../unit/puList.php?mod=".$row["module"]."&xsn=".XSN).
			" title=\""._t("List of process-units")." '".sxHE($row["description"])."'\">".
			"<img src='../../_img/b_engine.png' border='0' /></a></td>" .
		"<td class=\"text01\" valign='top' width='90%' style='font-weight:bold;'><a class=\"text01\" ".
			goToPag("moduleView.php?mod=".$row["module"]."&xsn=".XSN).
			" title=\""._t("View module")." '".sxHE($row["m_description"])."'\">".
			strtoupper(sxHE($row["module"]))."</a> - ".strtoupper(sxHE($row["m_description"]))."</td>" .
		"<td class=\"text01\" valign='top' width='10%'><a class=\"link01\" ".
			goToPag("../crul/crulList.php?mod=".$row["module"]."&xsn=".XSN).
			" title=\""._t("List of common rules")." '".sxHE($row["description"])."'\">".
			"rules</a>&nbsp;<a class=\"link01\" ".
			goToPag("../layo/layoutSetList.php?mod=".$row["module"]."&xsn=".XSN).
			" title=\""._t("List of layout-sets")." '".sxHE($row["description"])."'\">".
			"layouts</a>&nbsp;<a class=\"link01\" ".
			goToPag("../menu/menuPageList.php?mod=".$row["module"]."&xsn=".XSN).
			" title=\""._t("List of menu")." '".sxHE($row["description"])."'\">".
			"menus</a></td>" .
		"</tr>\n");
	while($row && $module == $row["module"]){
		$funcArea = $row["functional_area"];
		echo("<tr>" .
			"<td class=\"text01\" valign='top' style='font-weight:bold;'><a class=\"text01\" ".
				goToPag("../unit/puList.php?mod=$module&fa=$funcArea&xsn=".XSN).
				" title=\""._t("List of process-units")." '".sxHE($row["description"])."'\">".
				"<img src='../../_img/b_engine.png' border='0' /></a></td>" .
			"<td class=\"text01\" valign='top' style='font-weight:bold;'>".
				"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".
				"<a class=\"text01\" ".goToPag("functionalAreaView.php".
				"?mod=".$row["module"]."&fa=".$row["functional_area"]."&xsn=".XSN).
				" title=\""._t("View functional-area")." '".sxHE($row["f_description"])."'\">".
				sxHE($row["functional_area"])."</a> - ".sxHE($row["f_description"])."</td>" .
				"<td class=\"text01\" align='right' colspan='3'>&nbsp;</td>" .
			"</tr>\n");
		while($row && $module == $row["module"] && $funcArea == $row["functional_area"]){
			$subMod = $row["sub_module"];
			echo("<tr>" .
				"<td class=\"text01\" valign='top' style='font-weight:bold;'><a class=\"text01\" ".
					goToPag("../unit/puList.php?mod=$module&sub=$subMod&xsn=".XSN).
					" title=\""._t("List of process-units")." '".sxHE($row["description"])."'\">".
					"<img src='../../_img/b_engine.png' border='0' /></a></td>" .
				"<td class=\"text01\" valign='top'>".
					"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".
					"<a class=\"text01\" ".goToPag("subModView.php".
					"?mod=".$row["module"]."&sub=".$row["sub_module"]."&xsn=".XSN).
					" title=\""._t("View sub-module")." '".sxHE($row["s_description"])."'\">".
					sxHE($subMod)."</a> - ".sxHE($row["s_description"])."</td>" .
				"<td class=\"text01\" align='right' colspan='3'>&nbsp;</td>" .
				"</tr>\n");
			$row = $objSDAO->fetch("mod");
		}
	}
}
echo("</table>\n");
echo(commandsHTML($aCmd));
echo(footerHTML());
